package chenji.itemeditor.itemeditor;

public enum AttributeType {
	MAX_HEALTH("generic.maxHealth", 1), FOLLOW_RANGE("generic.followRange", 2), KNOCKBACK_RESISTANCE("generic.knockbackResistance", 3), MOVEMENT_SPEED("generic.movementSpeed",
			4), ATTACK_DAMAGE("generic.attackDamage", 5), ARMOR("generic.armor", 6), ARMOR_TOUGHNESS("generic.armorToughness", 7), ATTACK_SPEED("generic.attackSpeed", 8), LUCK("generic.luck", 9);

	private String type;
	private int id;

	AttributeType(String typeString, int id) {
		this.type = typeString;
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public int getID() {
		return this.id;
	}

	public static AttributeType getByID(int id) {
		switch (id) {
		case 1:
			return AttributeType.MAX_HEALTH;
		case 2:
			return AttributeType.FOLLOW_RANGE;
		case 3:
			return AttributeType.KNOCKBACK_RESISTANCE;
		case 4:
			return AttributeType.MOVEMENT_SPEED;
		case 5:
			return AttributeType.ATTACK_DAMAGE;
		case 6:
			return AttributeType.ARMOR;
		case 7:
			return AttributeType.ARMOR_TOUGHNESS;
		case 8:
			return AttributeType.ATTACK_SPEED;
		case 9:
			return AttributeType.LUCK;
		}
		return null;
	}

	public static AttributeType loadFromString(String name) {
		if (name == null) {
			return null;
		}
		try {
			return AttributeType.valueOf(name.toUpperCase());
		} catch (Exception e) {

		}
		switch (name) {
		case "generic.maxHealth":
			return AttributeType.MAX_HEALTH;
		case "generic.followRange":
			return AttributeType.FOLLOW_RANGE;
		case "generic.knockbackResistance":
			return AttributeType.KNOCKBACK_RESISTANCE;
		case "generic.movementSpeed":
			return AttributeType.MOVEMENT_SPEED;
		case "generic.attackDamage":
			return AttributeType.ATTACK_DAMAGE;
		case "generic.armor":
			return AttributeType.ARMOR;
		case "generic.armorToughness":
			return AttributeType.ARMOR_TOUGHNESS;
		case "generic.attackSpeed":
			return AttributeType.ATTACK_SPEED;
		case "generic.luck":
			return AttributeType.LUCK;
		}
		return null;
	}

}
